home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 6_11.lha / 6_11 / 6_11_eq1.c < prev    next >
Text File  |  1993-08-08  |  856b  |  39 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. *
  6.    Assignment operator for type arbint.
  7. /
  8. include <arbint.h>
  9.  
  10. rbint& arbint::operator=(arbint &x)    // x = y;
  11.  
  12.    x.p->refcnt++;
  13.    if (--p->refcnt == 0)
  14. {
  15. delete p->value;
  16. delete p;
  17. }
  18.  
  19.    p = x.p;
  20.    return *this;
  21.  
  22. / DELETE    
  23. / DELETE    arbint& arbint::operator=(const arbint &x)    // x = y;
  24. / DELETE    {d// DELETE        if (--p->refcnt == 0)
  25. / DELETE        {
  26. / DELETE        delete p->value;
  27. / DELETE        delete p;
  28. / DELETE        }
  29. / DELETE    
  30. / DELETE        p = new arep;
  31. / DELETE        int nlen = x.p->length;
  32. / DELETE        p->length = nlen;
  33. / DELETE        p->value = new ARB_type[nlen];
  34. / DELETE        p->refcnt = 1;
  35. / DELETE        memcpy((char*)p->value, (char*)x.p->value,
  36. / DELETE        nlen * sizeof(ARB_type));
  37. / DELETE        return *this;
  38. / DELETE    }
  39.